﻿using B.S.Warehouse.ErrorCord;
using B.S.Warehouse.Write.Api.Application.Command.AllocateCommand;
using B.S.Warehouse.Write.Api.Application.Command.AllocationDetailsCommand;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Warehouse.Write.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AllocateController : ControllerBase
    {
        private readonly IMediator mediator;
        public AllocateController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 调拨申请添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<object>> AddAllocate(AddAllocateCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 调拨申请删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<ApiResult<int>> DelAllocate([FromQuery] DelAllocateCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 调拨申请修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdateAllocate(UpdateAllocateCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 调拨申请明细添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<object>> AddAllocationDetail(AddAllocationDetailsCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 调拨申请明细删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<ApiResult<int>> DelAllocationDetails([FromQuery] DelAllocationDetailsCommand request)
        {
            return await mediator.Send(request);
        }
        // <summary>
        /// 调拨申请明细删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdateAllocationDetails(UpdateAllocationDetailsCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
